<template>
  <div class="feedback unified-bg color-9">
    <div class="main " style="position: relative">
      <div class="list-warp"
           v-infinite-scroll="loadMore1"
           infinite-scroll-disabled="feedLloading"
           infinite-scroll-immediate-check="false"
           infinite-scroll-distance="10">
        <div class="center" v-for="(item, index) in feedArr">
          <ul class="main-ul boxShadow">
            <li>
              <div class="sn color-9">
                <p>设备编码： <span>{{ item.sn }}</span></p>
              </div>
              <div class="li-sub1">
                <p>用户： <i>{{ item.userName }}</i></p>
                <p>反馈时间： <span>{{ item.createTime }}</span></p>
              </div>
              <div class="li-sub2">
                反馈内容： <span>{{ item.feedbackContent }}</span>
              </div>
            </li>
          </ul>
        </div>

        <div class="weui-loadmore" v-show="loading">
          <i class="weui-loading"></i>
          <span class="weui-loadmore__tips">正在加载</span>
        </div>
        <noData v-if="feedArr == 0 && !debut">
          <p>暂无数据</p>
        </noData>
        <div class="weui-loadmore weui-loadmore_line" v-show="noData" v-else>
          <span class="weui-loadmore__tips">我是有底线的</span>
        </div>

      </div>
    </div>
  </div>
</template>
<script>
  import * as api from 'api';
  import noData from '@/components/noData';
  export default {
    data () {
      return {
        debut: true,
        feedLloading: true,
        loading: false,
        noData: false,
        page: 0,
        feedArr: []
      }
    },
    methods: {
      query (loadMore) {
        api.checkFeedback({
          agencyId: this.$store.state.userInfo.id,
          limit: 10,
          offset: this.page * 10 || 0
        })
          .then(res => {
            this.debut = false
            res.resultData.forEach((item, index) => {
              item.createTime = item.createTime.slice(0, 10);
            })
            if (loadMore) {
              if (this.feedArr.length >= res.total) {
                this.feedLloading = true;
                this.loading = false;
                this.noData = true;
              } else {
                this.feedArr = this.feedArr.concat(res.resultData);
                console.log(res.resultData)
                this.feedLloading = false;
                this.loading = false;
              }
            } else {
              console.log(res.resultData)
              this.feedArr = res.resultData;
              this.feedLloading = false;
            }
          })
      },
      loadMore1 () {
        this.page++;
        this.feedLloading = true;
        this.loading = true;
        this.query(true)
      }
    },
    created () {
      this.query()
    },
    components: {
      noData
    },
    mounted () {
      this.title('反馈意见');
    }
  }
</script>
<style lang="scss" scoped>
  @import '../../../styles/agent/personal/feedback';
  .list-warp {
    @include borderRadius(5px);
  }
</style>
